<!doctype html>



  


<html class="theme-next muse use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.1" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="Samba," />








  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.1.1" />






<meta name="description" content="&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;samba 服务可以实现 windows 和 linux 的文件共享，配置不难，使用也非常简单。 1.samba 配置文件 smb.conf&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;安装系统的时候大多会默认安装 samba ，如果没有安装，在 cen">
<meta name="keywords" content="Samba">
<meta property="og:type" content="article">
<meta property="og:title" content="samba部署和优化">
<meta property="og:url" content="https://hcldirgit.github.io/2017/09/03/Samba/1. samba部署和优化/index.html">
<meta property="og:site_name" content="失落的乐章">
<meta property="og:description" content="&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;samba 服务可以实现 windows 和 linux 的文件共享，配置不难，使用也非常简单。 1.samba 配置文件 smb.conf&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;安装系统的时候大多会默认安装 samba ，如果没有安装，在 cen">
<meta property="og:locale" content="zh-Hans">
<meta property="og:image" content="https://github.com/hcldirgit/image/blob/master/samba%E9%83%A8%E7%BD%B2%E5%92%8C%E4%BC%98%E5%8C%96/01.png?raw=true">
<meta property="og:image" content="https://github.com/hcldirgit/image/blob/master/samba%E9%83%A8%E7%BD%B2%E5%92%8C%E4%BC%98%E5%8C%96/02.png?raw=true">
<meta property="og:updated_time" content="2017-09-02T17:33:16.171Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="samba部署和优化">
<meta name="twitter:description" content="&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;samba 服务可以实现 windows 和 linux 的文件共享，配置不难，使用也非常简单。 1.samba 配置文件 smb.conf&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;安装系统的时候大多会默认安装 samba ，如果没有安装，在 cen">
<meta name="twitter:image" content="https://github.com/hcldirgit/image/blob/master/samba%E9%83%A8%E7%BD%B2%E5%92%8C%E4%BC%98%E5%8C%96/01.png?raw=true">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Muse',
    sidebar: {"position":"left","display":"post","offset":12,"offset_float":0,"b2t":false,"scrollpercent":false},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="https://hcldirgit.github.io/2017/09/03/Samba/1. samba部署和优化/"/>





  <title>samba部署和优化 | 失落的乐章</title>
</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  




<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
            (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
          m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
  ga('create', '85*****1', 'auto');
  ga('send', 'pageview');
</script>


  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?87980c**************99ec5e26fb5";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>











  
  
    
  

  <div class="container sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">失落的乐章</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">技术面前，永远都是学生。</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-message">
          <a href="/message" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-external-link"></i> <br />
            
            留言
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
    <link itemprop="mainEntityOfPage" href="https://hcldirgit.github.io/2017/09/03/Samba/1. samba部署和优化/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="失落的乐章">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/0.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="失落的乐章">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">samba部署和优化</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-09-03T02:11:54+08:00">
                2017-09-03
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    <div class="post-body" itemprop="articleBody">

      
      

      
        <p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;samba 服务可以实现 windows 和 linux 的文件共享，配置不难，使用也非常简单。</p>
<h2 id="1-samba-配置文件-smb-conf"><a href="#1-samba-配置文件-smb-conf" class="headerlink" title="1.samba 配置文件 smb.conf"></a>1.samba 配置文件 smb.conf</h2><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;安装系统的时候大多会默认安装 samba ，如果没有安装，在 centos 上只需要运行</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">[root@192 ~]<span class="comment"># yum install -y samba samba-client</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;samba 配置文件为 /etc/samba/smb.conf ，通过修改这个配置文件来完成各种需求。打开配置文件，发现很多内容都用 # 或者 ； 注释掉了，先看一下未被注释的部分</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div></pre></td><td class="code"><pre><div class="line">[global]</div><div class="line">    workgroup = MYGROUP</div><div class="line">    server string = Samba Server Version %v</div><div class="line">    security = user</div><div class="line">    passdb backend = tdbsam</div><div class="line">    load printers = yes</div><div class="line">    cups options = raw</div><div class="line">[homes]</div><div class="line">    comment = Home Directories</div><div class="line">    browseable = no</div><div class="line">    writable = yes</div><div class="line">[printers]</div><div class="line">    comment = All Printers</div><div class="line">    path = /var/spool/samba</div><div class="line">    browseable = no</div><div class="line">    guest ok = no</div><div class="line">    writable = no</div><div class="line">    printable = yes</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;主要有以上三个部分：<strong>[global] , [homes] , [printers]</strong></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>[global]</strong> 定义全局的配置， workgroup 用来定义工作组，相信如果安装过 windows 系统，都会对这个 workgroup 不陌生。一般情况下，需要把这里的 MYGROUP 改成 WORKGROUP （windows 默认的工作组名字）。</p>
<ul>
<li><strong>security = user</strong> ：这里指定 samba 的安全等级。关于安全等级有四种：</li>
<li><p><strong>share</strong> ：用户不需要帐号密码即可登录 samba 服务器</p>
</li>
<li><p><strong>user</strong> ：由提供服务的 samba 服务器负责检查账户及密码（默认）</p>
</li>
<li><p><strong>server</strong> ：检查账户及密码的工作由另一台 windows 或 samba 服务器负责</p>
</li>
<li><p><strong>domain</strong> ：指定 windows 域控制服务器来验证用户的账户及密码</p>
</li>
<li><p><strong>passdb bankend = tdbsam</strong> ：passdb backend （用户后台），samba有三种用户后台：<strong>smbpasswd，tdbsam 和 ldapsam</strong>。</p>
</li>
<li><p><strong>smbpasswd</strong> ：该方式是使用 smb 工具 smbpasswd 给系统用户（真实用户或者虚拟用户）设置一个 samba 密码，客户端就用此密码访问 samba 资源。smbpasswd 在 /etc/samba 中，有时需要手工创建该文件。</p>
</li>
<li><p><strong>tdbsam</strong>：使用数据库文件创建用户数据库。数据库文件叫 passdb.tdb，在 /etc/samba 中。passdb.tdb 用户数据库可使用 smbpasswd -a 创建 samba 用户，要创建的 samba 用户必须先是系统用户。也可以使用 pdbedit 创建 samba 账户。pdbedit 参数很多，其中主要的有：</p>
</li>
<li><p><strong>pdbedt -a username</strong> ：新建 samba 账户</p>
</li>
<li><p><strong>pdbedit -x username</strong> ：删除 samba 账户</p>
</li>
<li><p><strong>pdbedit -L</strong> ：列出 samba 用户列表，读取 passdb.tdb 数据库文件</p>
</li>
<li><p><strong>pdbedit -Lv</strong> ：列出 samba 用户列表详细信息</p>
</li>
<li><p><strong>pdbedit -c “[D]” -u username</strong> ：暂停该 samba 用户帐号</p>
</li>
<li><p><strong>pdbeidt -c “[]” -u username</strong> ：恢复该 samba 用户帐号</p>
</li>
<li><p><strong>ldapsam</strong> ：基于 LDAP  账户管理方式验证用户。首先要建立 LDAP 服务，设置 “passdb backend = ldapsam：ldap://LDAP Server”</p>
</li>
</ul>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;load printers 和 cups options 两个参数用来设置打印机相关</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;除了这些参数外，还有几个参数需要了解：</p>
<ul>
<li><p><strong>netbios name = MYSERVER</strong> ：设置出现在网上邻居中的主机名</p>
</li>
<li><p><strong>hosts allow = 127.192.168.12.192.168.13</strong> ：用来设置允许的主机，如果在前面加 “；” 则表示允许所有主机。</p>
</li>
<li><p><strong>log file =  /var/log/samba/%m.log</strong> ：定义 samba 的日志，这里的 %m 是上面的 netbios name</p>
</li>
<li><p><strong>max log size = 50</strong> ：指定日志的最大容量，单位是K</p>
</li>
</ul>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;[home] 该部分内容共享用户子机的家目录，也就是说，当用户登录到 samba 服务器上时，实际上是进入到了该用户的家目录，用户登录后，共享名不是 homes 而是用户子机的标识符，对于单纯的文件共享的环境来说这部分可以注释掉。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;[printers] 该部分内容设置打印机共享</p>
<h2 id="2-samba实践"><a href="#2-samba实践" class="headerlink" title="2.samba实践"></a>2.samba实践</h2><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;samba 可以实现 linux 和 windows 机器相互共享文件，非常实用。下面实践几个应用。</p>
<h3 id="A-samba-实践一"><a href="#A-samba-实践一" class="headerlink" title="A.samba 实践一"></a>A.samba 实践一</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;要求：共享一个目录，任何人都可以访问，即不用输入密码即可访问，要求制度</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;打开 samba 配置文件 /etc/samba/smb.conf</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">[root@192 ~]<span class="comment"># vim /etc/samba/smb.conf</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;在 [global] 部分把：MYGROUP 改成 WORKGROUP ，把 security = user 修改为 security = share 。然后在文件的最末尾处加入以下内容：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div></pre></td><td class="code"><pre><div class="line">[share]</div><div class="line">comment = share all</div><div class="line">path = /tmp/samba</div><div class="line">browseable = yes</div><div class="line">public = yes</div><div class="line">writable = no</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;创建测试目录：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">[root@192 ~]<span class="comment"># mkdir /tmp/samba</span></div><div class="line">[root@192 ~]<span class="comment"># chmod 777 /tmp/samba</span></div><div class="line">[root@192 ~]<span class="comment"># touch /tmp/samba/sharefiles</span></div><div class="line">[root@192 ~]<span class="comment"># echo "111111" &gt; /tmp/samba/sharefiles</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;启动 samba 服务：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">[root@192 ~]<span class="comment"># /etc/init.d/smb start</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;测试能否试验要求，首先测试配置的 smb.conf 是否正确，使用命令：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">[root@192 ~]<span class="comment"># testparm</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;会看到一个警告：<code>WARNING: The security=share option is deprecated</code> ，不过影响不大，无需管它。如果没有错就在 windows 机器上的浏览器中输入：file://192.168.0.73/sharefiles 看能否访问到</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;在 linux 机器上输入：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">[root@192 ~]<span class="comment"># smbclient //192.168.0.73/share</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;还有个方法就是挂载，在挂载前先安装</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">[root@192 ~]<span class="comment"># yum install -y cifs-utils</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;挂载</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">[root@192 ~]<span class="comment"># mount -t cifs //192.168.0.73/share /opt/</span></div></pre></td></tr></table></figure>
<p><img src="https://github.com/hcldirgit/image/blob/master/samba%E9%83%A8%E7%BD%B2%E5%92%8C%E4%BC%98%E5%8C%96/01.png?raw=true" alt=""></p>
<h3 id="B-samba-实践二"><a href="#B-samba-实践二" class="headerlink" title="B.samba 实践二"></a>B.samba 实践二</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;要求：共享一个目录，使用用户名和密码登录后才可以访问，要求可以读写：</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;打开 samba 的配置文件 /etc/samba/smb.conf</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">[root@192 ~]<span class="comment"># vim /etc/samba/smb.conf</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;[global] 部分内容如下：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line">[global]</div><div class="line">        workgroup = WORKGROUP</div><div class="line">        server string = Samba Server Version %v</div><div class="line">        security = user</div><div class="line">        passdb backend = tdbsam</div><div class="line">        load printers = yes</div><div class="line">        cups options = raw</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;还需要加入一下内容：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div></pre></td><td class="code"><pre><div class="line">[myshare]</div><div class="line">        comment = share <span class="keyword">for</span> users</div><div class="line">        path = /samba</div><div class="line">        browseable = yes</div><div class="line">        writable = yes</div><div class="line">        public = no</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;保存配置文件，创建目录：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">[root@192 ~]<span class="comment"># mkdir /samba</span></div><div class="line">[root@192 ~]<span class="comment"># chmod 777 /samba</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;然后添加用户。因为在 [global] 中 “passdb backend = tdbsam”，所以要使用 pdbedit 来增加用户，注意添加的用户必须在系统中存在，所以需要先创建系统帐号：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">[root@192 ~]<span class="comment"># useradd user1</span></div><div class="line">[root@192 ~]<span class="comment"># useradd user2</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;然后添加 user1 为 samba 帐号：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">[root@192 ~]<span class="comment"># pdbedit -a user1</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;在添加 user2 为 samba 帐号：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">[root@192 ~]<span class="comment"># pdbedit -a user2</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;列出 samba 的所有帐号：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">[root@192 ~]<span class="comment"># pdbedit -L</span></div><div class="line">user1:503:</div><div class="line">user2:504:</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;重启 samba 服务</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">[root@192 ~]<span class="comment"># service smb restart</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;测试</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;打开浏览器输入 file://192.168.0.73/myshare 弹出窗口后输入帐号和密码登录</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;linux 机器登录</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;具体语法为：smbclient //IP/共享名 -U 用户名</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">[root@192 ~]<span class="comment"># smbclient //192.168.0.73/myshare -U user1</span></div></pre></td></tr></table></figure>
<p><img src="https://github.com/hcldirgit/image/blob/master/samba%E9%83%A8%E7%BD%B2%E5%92%8C%E4%BC%98%E5%8C%96/02.png?raw=true" alt=""></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;可以用 “？” 列出所有可以使用的命令。常用的有 cd，ls，rm，pwd，tar ，mkdir，chown，get，put等，使用 help+ 命令 可以打印该命令如何使用，其中 get 是下载，put 是上传。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;另外还可以通过挂载方式</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">[root@192 ~]<span class="comment"># mount -t cifs //192.168.0.73/myshare /mnt -o username=user2,password=123456</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;要指定 -t cifs //IP/共享名 本地挂载点 -o后面跟 username 和 password 挂载完后就可以像使用本地的目录一样使用共享目录了，注意共享名后面不能有斜杠。</p>

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/Samba/" rel="tag"># Samba</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2017/09/03/Saltstack/1. Saltstack 安装配置/" rel="next" title="resin安装与配置">
                <i class="fa fa-chevron-left"></i> resin安装与配置
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2017/09/03/Samba/2. Samba服务器（多用户组、多用户有不同的访问权限）/" rel="prev" title="Samba服务器（多用户组、多用户有不同的访问权限）">
                Samba服务器（多用户组、多用户有不同的访问权限） <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/images/0.png"
               alt="失落的乐章" />
          <p class="site-author-name" itemprop="name">失落的乐章</p>
           
              <p class="site-description motion-element" itemprop="description">失落的乐章的Blog</p>
          
        </div>
        <nav class="site-state motion-element">

          
            <div class="site-state-item site-state-posts">
              <a href="/">
                <span class="site-state-item-count">627</span>
                <span class="site-state-item-name">日志</span>
              </a>
            </div>
          

          

          
            
            
            <div class="site-state-item site-state-tags">
              <a href="/tags/index.html">
                <span class="site-state-item-count">38</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://github.com/hcldirgit" target="_blank" title="GitHub">
                  
                    <i class="fa fa-fw fa-github"></i>
                  
                  GitHub
                </a>
              </span>
            
          
        </div>

        
        

        
        

        


      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-samba-配置文件-smb-conf"><span class="nav-number">1.</span> <span class="nav-text">1.samba 配置文件 smb.conf</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-samba实践"><span class="nav-number">2.</span> <span class="nav-text">2.samba实践</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#A-samba-实践一"><span class="nav-number">2.1.</span> <span class="nav-text">A.samba 实践一</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#B-samba-实践二"><span class="nav-number">2.2.</span> <span class="nav-text">B.samba 实践二</span></a></li></ol></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy; 
  <span itemprop="copyrightYear">2017</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">失落的乐章</span>
</div>


<div class="powered-by">
  由 <a class="theme-link" href="https://hexo.io">Hexo</a> 强力驱动
</div>

<div class="theme-info">
  主题 -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Muse
  </a>
</div>


        

        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.1"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.1"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.1"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.1"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.1"></script>



  


  




	





  





  





  






  





  

  

  

  

  

  

</body>
</html>
